﻿package ygg.encoding.amf.type.v3
{
	import ygg.encoding.amf.type.*;
	import j.sus2maj7.encoding.*;
	
	public class DateCodec extends ComplexCodec
	{
		public function DateCodec()
		{
			
		}
		
		override protected function decodeComplex(u:uint, binary:IBinary, context:IContext=null):*
		{
			var retVal:Date = new Date();
			retVal.setTime( binary.readDouble() );
			return retVal;
		}
		
		override protected function encodeComplex(o:Object, b:IBinary, context:IContext=null):void
		{
			b.writeByte(1);
			b.writeDouble( (o as Date).getTime() );
			
		}
		override protected function getMarker():uint
		{
			return Amf3Marker.DATE;
		}
	}
}